package regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created with IntelliJ IDEA
 * Description:正则非捕获分组
 * User:22954
 * Date:2024-05-29
 * Time:11:02
 */
public class Rule6 {
    /*
    (?:pattern)----匹配pattern但不捕获成分组    对(|)的简化写法有明显效果
    (?=pattern)----非捕获匹配    字串包含pattern能通过匹配
    (?!pattern)----非捕获匹配    字串不包含pattern才能通过匹配
     */
    public static void main(String[] args) {
        String content = "industry1111 234industries Windows9 Windows11 WindowsNT";
        String regex = "industr(?:y|ies)";
        regex = "Windows(?=9|11)";
        regex = "Windows(?!9|11)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(content);
        while(matcher.find()){
            System.out.println(matcher.group(0));
        }
    }
}
